home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / LISTMANA / __TESTER / TESTERMA.C < prev    next >
C/C++ Source or Header  |  1989-06-25  |  4KB  |  204 lines

  1. /****                                                                    */
  2. /****    Code Testing System version 1.0 (beta)                            */
  3. /****                                                                    */
  4. /****    All portions of this source code are the property of Jack        */
  5. /****    Herrington.  I, Jack Herrington, give you permission to use        */
  6. /****    use or alter the code in any way that pleases you.  You must    */
  7. /****    however return by whatever means avaliable any improvements        */
  8. /****    you believe significant to Jack Herrington, accepting that        */
  9. /****    these improvements might be contained in later releases of        */
  10. /****    the code. I also grant you permission to remove this header        */
  11. /****    from any file you are WORKING on, as long as you put it back    */
  12. /****    when you're stopped WORKING on it.                                */
  13. /****                                                                    */
  14. /****    Jack Herrington: University Of Miami, Biomedical Computing        */
  15. /****                     1600 N.W. 10th Ave. (R-53)                        */
  16. /****                     (305) 547-6538                                    */
  17. /****                                                                    */
  18.  
  19. /****/
  20. /**** Tester main */
  21. /****/
  22.  
  23. #define MAIN
  24. #include "ListManager.h"
  25. #include "Tester.h"
  26.  
  27. /****/
  28. /**** Main event loop processor */
  29. /****/
  30.  
  31. main()
  32. {
  33.     unsigned char ch;
  34.     EventRecord ev;
  35.     WindowPtr win;
  36.     int st,hit,hand,wnum,fwr;
  37.  
  38.     InitQuickDraw();
  39.     TestMenuSetup();
  40.  
  41.     for(hand=0;;hand++)
  42.     {
  43.         if(Handlers[hand].preLaunch == (-1))break;
  44.         if(Handlers[hand].preLaunch == BOOT_FIRST)
  45.         {
  46.             TesterOpenHandler(hand);
  47.         }
  48.     }
  49.     bootHandler = (-1);
  50.  
  51.     st=0;
  52.     while(st==0)
  53.     {
  54.         if(GetNextEvent(-1,&ev)==1)
  55.         {
  56.             if(IsDialogEvent(&ev)==TRUE)
  57.             {
  58.                 if ( ev.what == updateEvt )
  59.                 {
  60.                     TesterUpdate(TesterFindProgWindow((WindowPtr)ev.message));
  61.                 }
  62.                 else if ( ev.what == activateEvt )
  63.                 {
  64.                     TesterActivate((WindowPtr)ev.message);
  65.                 }
  66.                 else if ( ev.what == keyDown || ev.what == autoKey )
  67.                 {
  68.                     ch = (unsigned char)(ev.message & charCodeMask);
  69.                     TesterKey(TesterFindProgWindow(FrontWindow()),ch);
  70.                 }
  71.                 if(DialogSelect(&ev,&win,&hit)==TRUE)TesterHitInWindow(win,hit);
  72.             }
  73.             else
  74.             {
  75.                 if (ev.what == mouseDown)
  76.                 {
  77.                     fwr=FindWindow(ev.where,&win);
  78.                     if(FrontWindow()!=win && win!=0L)SelectWindow(win);
  79.                     else st=TesterMouseClick(&ev,fwr,win);
  80.                 }
  81.             }
  82.         }
  83.  
  84.         if ( bootHandler != (-1) )
  85.         {
  86.             TesterOpenHandler(bootHandler);
  87.             bootHandler = (-1);
  88.         }
  89.         else SystemTask();
  90.     }
  91.  
  92.     for(wnum=0;wnum<MAX_WINDOWS;wnum++)
  93.     {
  94.         if(Windows[wnum].window != 0L)TesterCloseWindow(wnum);
  95.     }
  96. }
  97.  
  98. /****/
  99. /**** Respond to a mouse click */
  100. /****/
  101.  
  102. int TesterMouseClick(ev,fwr,win)
  103. EventRecord *ev;
  104. int fwr;
  105. WindowPtr win;
  106. {
  107.     Point fcp;
  108.     long ms;
  109.     int cw,st;
  110.  
  111.     st=0;
  112.     switch(fwr)
  113.     {
  114.     case inMenuBar:
  115.         if((ms=MenuSelect(ev->where))==0)break;
  116.         st = TesterMenu(ms);
  117.         break;
  118.     case inDrag:
  119.         DragWindow(win,ev->where,&dragRect);
  120.         break;
  121.     case inSysWindow:
  122.         SystemClick(ev,win);
  123.         break;
  124.     case inGoAway:
  125.         if(TrackGoAway(win,ev->where)==1)
  126.             if((cw=TesterFindProgWindow(win))!=(-1))TesterCloseWindow(cw);
  127.         break;
  128.     case inGrow:
  129.         TesterSendGrow(TesterFindProgWindow(win));
  130.         break;
  131.     }
  132.     return st;
  133. }
  134.  
  135. /****/
  136. /**** Menu handler */
  137. /****/
  138.  
  139. int TesterMenu(menuSel)
  140. long menuSel;
  141. {
  142.     int st;
  143.     st=0;
  144.     switch(HiWord(menuSel))
  145.     {
  146.     case 128:
  147.         RunDialog(3000);
  148.         break;
  149.     case 129:
  150.         st=(-1);
  151.         break;
  152.     case 130:
  153.         break;
  154.     case 131:
  155.         bootHandler = LoWord(menuSel)-1;
  156.         break;
  157.     }
  158.     HiliteMenu(0);
  159.     return st;
  160. }
  161.  
  162. /****/
  163. /**** Initialize all of the quickdraw stuff */
  164. /****/
  165.  
  166. InitQuickDraw()
  167. {
  168.     GrafPort myGrafPort;
  169.     int win;
  170.  
  171.         /**** Initialize quickdraw */
  172.  
  173.     InitGraf(&thePort);
  174.     OpenPort(&myGrafPort);
  175.     InitFonts();
  176.     InitWindows();
  177.     InitMenus();
  178.     TEInit();
  179.     InitDialogs(0L);
  180.     InitCursor();
  181.  
  182.         /**** Create window drag area */
  183.  
  184.     dragRect.left=5;
  185.     dragRect.top=32;
  186.     dragRect.bottom=thePort->portRect.bottom-16;
  187.     dragRect.right=thePort->portRect.right-5;
  188.  
  189.         /**** Startup the random numbers */
  190.  
  191.     GetDateTime(&randSeed);
  192.  
  193.         /**** Reset the window */
  194.  
  195.     for(win=0;win<MAX_WINDOWS;win++)
  196.     {
  197.         Windows[win].window = 0L;
  198.         Windows[win].data = 0L;
  199.         Windows[win].handler = (-1);
  200.     }
  201.  
  202.     growBoxHandle=GetPicture(1001);
  203. }
  204.